<?php

class News extends BaseTopic implements iEditBody {
	public function prepare($new, $item, $inputs) {
		return $this->create_body("Nieuwsbericht", $item, $inputs);
	}

	public function get_edit_body() {
		$sql = $this->db_access->db_query_select(
				array(
						array('*')), 
				array("NEWS"), 
				"item_id = {$this->id}");
		$sqlresult = $this->db_access->db_do_query($sql);
		$news = $this->db_access->db_fetch_array($sqlresult);
		return $news['body'];
	}

	public function check_content($values, $new) {
		$ok = $this->checker->check_tags_advanced($values['body'], "body");
		$ok = $ok && $this->checker->check_tag_closures($values['body']);
		return $ok && $this->checker->check_exists($values['body'], "body");
	}

	protected function derive_info() {
		$info = strip_tags($_POST['body']);
		return substr($info, 0, 50) . ((strlen($info) > 50) ? "&hellip;" : "");
	}

	protected function get_sql_from_post($item_id) {
		return db_query_insert(array('item_id', 'body'), array($item_id, db_sqlize($_POST['body'])), "NEWS");
	}
}

?>
